package panel.sunTime
{
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	
	import assists.HtmlText;
	import assists.Lang;
	import assists.SizeManager;
	import assists.SunTimeCommute;
	import assists.TextFieldUtils;
	import assists.URI;
	import assists.resource.ResourceLoader;
	
	import inerface.ISunTimePanel;
	
	import main.ClientConstants;
	
	import panel.viewSpots.StaticSlide;
	
	public class SunTimePanel extends Sprite implements ISunTimePanel
	{
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _lang:Lang;
		private var _uri:URI;
		private var _sunTime:SunTimeCommute;
		private var _sunTimeList:Array = [];
		
		private var _titleTxt:TextField = new TextField();
		private var _container:Sprite = new Sprite();
		private var _tipTxt:TextField = new TextField();
		
		public function SunTimePanel()
		{
			super();
		}
		
		public function init(stage:Stage, loader:ResourceLoader, lang:Lang, uri:URI=null):void
		{
			_stage = stage;
			_loader = loader;
			_lang = lang;
			_uri = uri;
			
			var date:Date = new Date();
			_sunTime = new SunTimeCommute(37.526390, 122.067617);
			_sunTimeList.push(_sunTime.getSunTime(date.fullYear,date.month + 1,date.date));
			_sunTimeList.push(_sunTime.getSunTime(date.fullYear,date.month + 1,date.date + 1));
			_sunTimeList.push(_sunTime.getSunTime(date.fullYear,date.month + 1,date.date + 2));
			
			_titleTxt.mouseEnabled = false;
			_titleTxt.autoSize = "left";
			TextFieldUtils.setHtmlText(_titleTxt,HtmlText.format("日出日落最佳观景地",0xffffff,24));
			
			_tipTxt.mouseEnabled = false;
			_tipTxt.autoSize = "left";
			TextFieldUtils.setHtmlText(_tipTxt,HtmlText.format("温馨提示：由于海拔原因会导致日出日落时间有10分钟左右的偏差值，早晚温差大，请您注意保暖",0xffffff));
			
			_container.y = SizeManager.UpGuideHeight;
			_container.addChild(_titleTxt);
			this.addChild(_container);
		}
		
		public function show():void
		{
//			显示日出日落组件
			for(var i:int=0;i<_sunTimeList.length;i++)
			{
				var item:SunTimeItem = new SunTimeItem(_stage,_loader,i);
				item.show(_sunTimeList[i]);
				item.y = i * item.height  * 1.2;
				_container.addChild(item);
			}
			_titleTxt.y = _container.height + item.height * 0.2;
			
			var picList:Array = [
				{pic:_loader.uiManager.generateBmp(_loader.uiManager.tehSun),desc:"<font color='#fff100'>天鹅湖</font>，绝佳的拍摄圣地，每年吸引大量摄影爱好者前往，当然这里美的不仅仅有天鹅！"},
				{pic:_loader.uiManager.generateBmp(_loader.uiManager.csSun),desc:"<font color='#fff100'>赤山风景区</font>，山海相依，佛音缭绕，体验别样的日出日落"},
				{pic:_loader.uiManager.generateBmp(_loader.uiManager.cst),desc:"<font color='#fff100'>成山头</font>，天尽头，中国最早看见海上日出的地方，你还等什么呢？"},
				{pic:_loader.uiManager.generateBmp(_loader.uiManager.ccSun),desc:"<font color='#fff100'>九顶铁槎山</font>，自古称为大东胜境，若遇上晨雾，则是如仙境般的地方"},
			];
			for(i=0;i<picList.length;i++)
			{
				var picItem:SunTimePicItem = new SunTimePicItem(_stage,_loader);
				picItem.show(picList[i]);
				picItem.y = _container.height;
				trace(picItem.height + "zzzzzzzzzzz");
				_container.addChild(picItem);
			}
			
			StaticSlide.beginSlide(_container,_stage,new Rectangle(0,_container.y,0,- _container.height + SizeManager.guideHeight),_container.y);
		}
		
		public function clear():void
		{
		}
	}
}